trigger for deleted objects

Hello,

I try to trigger a pop up when I delete an object.

But I'm very lost with triggers...

 

Can someone help me ?

 


Estebell - Fri Jan 13 04:54:23 EST 2017

Re: trigger for deleted objects
Mathias Mamsch - Fri Jan 13 06:13:16 EST 2017

There is lots of info on the forum on triggers, with many examples. 

The trigger table in the DXL Manual lists only the following events for "object": open, sync, drag, drop

Unfortunately I just confirmed, there seems to be noch such trigger, that will fire when an object is deleted.

So you probably need to come up with something else to satisfy the use case you are thinking about (which is?) 

Regards, Mathias

Re: trigger for deleted objects
PekkaMakinen - Fri Jan 13 08:02:24 EST 2017

The question by Mathias on your use case or need is quite relevant: what do you want to achive?

I have done a "delete" trigger, it was for one integration functionality: as soon as a user deleted an object in DOORS an export file was created. It worked as a pre-sync trigger, i.e. when the user was moving to another object the trigger fired and checked if the last detail in the history of the previous object was object deleted. Worked quite well, but not for level 1 objects, which we could live with.

Re: trigger for deleted objects
Estebell - Fri Jan 13 08:14:12 EST 2017

Well my need is there :

If an object has an inlink, when I try to delete it, a pop up fires with the information "Impossible to delete objects with inlinks."

I'd want to have the same behaviour with outlinks : when deleting an object with outlinks, a pop up should appear informing it's not possible and then cancel the deletion.

 

Re: trigger for deleted objects
PekkaMakinen - Fri Jan 13 10:20:12 EST 2017

Estebell - Fri Jan 13 08:14:12 EST 2017

Well my need is there :

If an object has an inlink, when I try to delete it, a pop up fires with the information "Impossible to delete objects with inlinks."

I'd want to have the same behaviour with outlinks : when deleting an object with outlinks, a pop up should appear informing it's not possible and then cancel the deletion.

 

You can set that behavior from the DOORS database options, starting from version 9.5.1 (?)

Re: trigger for deleted objects
Mathias Mamsch - Fri Jan 13 10:21:26 EST 2017

Estebell - Fri Jan 13 08:14:12 EST 2017

Well my need is there :

If an object has an inlink, when I try to delete it, a pop up fires with the information "Impossible to delete objects with inlinks."

I'd want to have the same behaviour with outlinks : when deleting an object with outlinks, a pop up should appear informing it's not possible and then cancel the deletion.

 

How about a pre/close trigger , informing the user that he has outlinks on deleted objects? 

Trigger t = null
DBE l = null

// function activated by trigger
bool trig_activation(Trigger t){
    Module m = module(t)

    bool closeable = true; 
    Object om; for om in entire m do {
       if (isDeleted om) {
         Link L; for L in om->"*" do {
             closeable = false; break
         }
       }
       if (!closeable) break; 
    }
    if (!closeable) ack "You have deleted objects with outlinks! Please fix!"; 
    return closeable ; 
}


void do_close(DB x){
    if ( ! null t ) { 
        string sErr= delete t
        if (!null sErr) print sErr
    }
    hide x;
}

// build the gui
DB test = create "Trigger Test"
l = label(test, "")
close (test, false, do_close)

realize(test)
setSize(test, 200, 110)


t = trigger(project->module->(fullName current Module), close, 5, trig_activation)
if (t == null) print "Trigger install failed!\n"; 

show test

Not the best usability ... Sync trigger is also a way to go, but also not 100% safe. Note the above example works only, while the GUI is opened. You would need to convert to a persistent trigger. 

Regards, Mathias

Re: trigger for deleted objects
Mathias Mamsch - Fri Jan 13 10:29:06 EST 2017

PekkaMakinen - Fri Jan 13 10:20:12 EST 2017

You can set that behavior from the DOORS database options, starting from version 9.5.1 (?)

really? nice ...

Re: trigger for deleted objects
PekkaMakinen - Fri Jan 13 11:02:14 EST 2017

Mathias Mamsch - Fri Jan 13 10:29:06 EST 2017

really? nice ...

Well, actually that option does not prevent you from deleting an object with out-links but just warns you when deleting such object. If I remember correctly.

Re: trigger for deleted objects
Estebell - Tue Jan 17 04:01:47 EST 2017

Mathias Mamsch - Fri Jan 13 10:21:26 EST 2017

How about a pre/close trigger , informing the user that he has outlinks on deleted objects? 

Trigger t = null
DBE l = null

// function activated by trigger
bool trig_activation(Trigger t){
    Module m = module(t)

    bool closeable = true; 
    Object om; for om in entire m do {
       if (isDeleted om) {
         Link L; for L in om->"*" do {
             closeable = false; break
         }
       }
       if (!closeable) break; 
    }
    if (!closeable) ack "You have deleted objects with outlinks! Please fix!"; 
    return closeable ; 
}


void do_close(DB x){
    if ( ! null t ) { 
        string sErr= delete t
        if (!null sErr) print sErr
    }
    hide x;
}

// build the gui
DB test = create "Trigger Test"
l = label(test, "")
close (test, false, do_close)

realize(test)
setSize(test, 200, 110)


t = trigger(project->module->(fullName current Module), close, 5, trig_activation)
if (t == null) print "Trigger install failed!\n"; 

show test

Not the best usability ... Sync trigger is also a way to go, but also not 100% safe. Note the above example works only, while the GUI is opened. You would need to convert to a persistent trigger. 

Regards, Mathias

Thank you for all your need.

I will convert that trigger to a persistant one.